package model.admin;
import vo.*;
import myutil.Connect;
import java.sql.*;
import java.util.ArrayList;
public class PopulateStudentsListMo {
	ArrayList<StudentDetailsVo> list=new ArrayList<StudentDetailsVo>(); 
	public ArrayList<StudentDetailsVo> populatelist() throws Exception{
		String query="select * from student_details where status='Active'";
		Connect c=new Connect();
		ResultSet rs=c.getResult(query);
		while(rs.next()){
			StudentDetailsVo single_object=new StudentDetailsVo();
			single_object.setStudent_id(rs.getInt("student_id"));
			single_object.setStudent_name(rs.getString("student_name"));
			single_object.setRoll_number(rs.getString("roll_number"));
			single_object.setRegistration_number(rs.getString("registration_number"));
			single_object.setMobile_number(rs.getString("mobile_number"));
			single_object.setPhone_number(rs.getString("phone_number"));
			single_object.setAddress_line_1(rs.getString("address_line_1"));
			single_object.setAddress_line_2(rs.getString("address_line_2"));
			single_object.setCity(rs.getString("city"));
			single_object.setCountry(rs.getString("country"));
			single_object.setEmail_id(rs.getString("email_id"));
			single_object.setDate_of_birth(rs.getString("date_of_birth"));
			single_object.setHighest_degree(rs.getString("highest_degree"));
			single_object.setHighest_degree_marks(rs.getInt("highest_degree_marks"));
			single_object.setHighest_degree_college_name(rs.getString("highest_degree_college_name"));
			single_object.setHighest_degree_passout_year(rs.getInt("highest_degree_passout_year"));
			single_object.setPrevious_degree_1(rs.getString("previous_degree_1"));
			single_object.setPrevious_degree_1_marks(rs.getInt("previous_degree_1_marks"));
			single_object.setPrevious_degree_1_college_name(rs.getString("previous_degree_1_college_name"));
			single_object.setPrevious_degree_1_passout_year(rs.getInt("previous_degree_1_passout_year"));
			single_object.setPrevious_degree_2(rs.getString("previous_degree_2"));
			single_object.setPrevious_degree_2_marks(rs.getInt("previous_degree_2_marks"));
			single_object.setPrevious_degree_2_college_name(rs.getString("previous_degree_2_college_name"));
			single_object.setPrevious_degree_2_passout_year(rs.getInt("previous_degree_2_passout_year"));
			single_object.setYears_of_experience(rs.getInt("years_of_experience"));
			single_object.setGender(rs.getString("gender"));
			single_object.setFather_name(rs.getString("father_name"));
			single_object.setPan_card_number(rs.getString("pan_card_number"));
			single_object.setPassport_number(rs.getString("passport_number"));
			single_object.setPassport_expiry_date(rs.getString("passport_expiry_date"));
			list.add(single_object);
			
		}
		return list;
		
	}
	
	
	public ArrayList<StudentDetailsVo> populateStudentInfo(int student_id) throws Exception{
		String query="select * from student_details where student_id="+student_id;
		System.out.println(query);
		Connect c=new Connect();
		ResultSet rs=c.getResult(query);
		while(rs.next()){
			StudentDetailsVo single_object=new StudentDetailsVo();
			single_object.setStudent_id(rs.getInt("student_id"));
			single_object.setStudent_name(rs.getString("student_name"));
			single_object.setRoll_number(rs.getString("roll_number"));
			single_object.setRegistration_number(rs.getString("registration_number"));
			single_object.setMobile_number(rs.getString("mobile_number"));
			single_object.setPhone_number(rs.getString("phone_number"));
			single_object.setAddress_line_1(rs.getString("address_line_1"));
			single_object.setAddress_line_2(rs.getString("address_line_2"));
			single_object.setCity(rs.getString("city"));
			single_object.setCountry(rs.getString("country"));
			single_object.setEmail_id(rs.getString("email_id"));
			single_object.setDate_of_birth(rs.getString("date_of_birth"));
			single_object.setHighest_degree(rs.getString("highest_degree"));
			single_object.setHighest_degree_marks(rs.getInt("highest_degree_marks"));
			single_object.setHighest_degree_college_name(rs.getString("highest_degree_college_name"));
			single_object.setHighest_degree_passout_year(rs.getInt("highest_degree_passout_year"));
			single_object.setPrevious_degree_1(rs.getString("previous_degree_1"));
			single_object.setPrevious_degree_1_marks(rs.getInt("previous_degree_1_marks"));
			single_object.setPrevious_degree_1_college_name(rs.getString("previous_degree_1_college_name"));
			single_object.setPrevious_degree_1_passout_year(rs.getInt("previous_degree_1_passout_year"));
			single_object.setPrevious_degree_2(rs.getString("previous_degree_2"));
			single_object.setPrevious_degree_2_marks(rs.getInt("previous_degree_2_marks"));
			single_object.setPrevious_degree_2_college_name(rs.getString("previous_degree_2_college_name"));
			single_object.setPrevious_degree_2_passout_year(rs.getInt("previous_degree_2_passout_year"));
			single_object.setYears_of_experience(rs.getInt("years_of_experience"));
			single_object.setGender(rs.getString("gender"));
			single_object.setFather_name(rs.getString("father_name"));
			single_object.setPan_card_number(rs.getString("pan_card_number"));
			single_object.setPassport_number(rs.getString("passport_number"));
			single_object.setPassport_expiry_date(rs.getString("passport_expiry_date"));
			list.add(single_object);
			
		}
		return list;
		
	}
	
	
	
	public void updateStudentList(int student_id,String student_name,String mobile_number,String phone_number,String address_line_1,String address_line_2,
									String city,String state,String country,String date_of_birth,String highest_degree,int highest_degree_marks,String highest_degree_college_name,
									int highest_degree_passout_year,String previous_degree_1,int previous_degree_1_marks,String previous_degree_1_college_name,
									int previous_degree_1_passout_year,String previous_degree_2,int previous_degree_2_marks,String previous_degree_2_college_name,
									int previous_degree_2_passout_year,int years_of_experience,String gender,String father_name,String pan_card_number,
									String passport_number,String passport_expiry_date,String type){
		String query;
		query="update student_details set student_name='"+student_name+"',mobile_number='"+mobile_number+"' ,phone_number='"+phone_number+"' ,"+
		"address_line_1='"+address_line_1+"' ,address_line_2='"+address_line_2+"' ,city='"+city+"' ,country='"+country+"' ,date_of_birth='"+date_of_birth+"' ,"+
		"highest_degree='"+highest_degree+"',highest_degree_marks="+highest_degree_marks+" ,highest_degree_college_name='"+highest_degree_college_name+"' ,"+
		"highest_degree_passout_year="+highest_degree_passout_year+" ,previous_degree_1='"+previous_degree_1+"' ,previous_degree_1_marks='"+previous_degree_1_marks+"' ,"+
		"previous_degree_1_college_name='"+previous_degree_1_college_name+"' ,previous_degree_1_passout_year="+previous_degree_1_passout_year+" ,"+
		"previous_degree_2='"+previous_degree_2+"' ,previous_degree_2_marks="+previous_degree_2_marks+" ,previous_degree_2_college_name='"+previous_degree_2_college_name+"' ,"+
		"previous_degree_2_passout_year="+previous_degree_2_passout_year+" ,years_of_experience="+years_of_experience+" ,gender='"+gender+"' ,father_name='"+father_name+"' ,"+
		"pan_card_number='"+pan_card_number+"' ,passport_number='"+passport_number+"' ,passport_expiry_date='"+passport_expiry_date+"' where student_id="+student_id;
		System.out.println(query);
		Connect c= new Connect();
		try {
			c.dml(query);
			c.logger(type, "Insert");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	

	public void insertStudentInfo(int student_id,String student_name,String roll_number,String registration_number,String mobile_number,
								String phone_number,String address_line_1,String address_line_2,String city,String state,String country,
								String email_id,String date_of_birth,String highest_degree,int highest_degree_marks,String highest_degree_college_name,
								int highest_degree_passout_year,String previous_degree_1,int previous_degree_1_marks,String previous_degree_1_college_name,
								int previous_degree_1_passout_year,String previous_degree_2,int previous_degree_2_marks,String previous_degree_2_college_name,
								int previous_degree_2_passout_year,int years_of_experience,String gender,String father_name,String pan_card_number,
								String passport_number,String passport_expiry_date,String status,String type){
String query;
query="insert into student_details(student_name,roll_number,registration_number,mobile_number,phone_number,address_line_1,address_line_2,city,state,country,"
+"email_id,date_of_birth,highest_degree,highest_degree_marks,highest_degree_college_name,highest_degree_passout_year,previous_degree_1,"
+"previous_degree_1_marks,previous_degree_1_college_name,previous_degree_1_passout_year,previous_degree_2,"
+"previous_degree_2_marks,previous_degree_2_college_name,previous_degree_2_passout_year,years_of_experience,"
+"gender,father_name,pan_card_number,passport_number,passport_expiry_date,status) values('"+student_name+"','"+roll_number+"','"+roll_number+"',"
+"'"+mobile_number+"','"+phone_number+"','"+address_line_1+"','"+address_line_2+"','"+city+"','"+state+"','"+country+"','"+email_id+"',"
+"'"+date_of_birth+"','"+highest_degree+"',"+highest_degree_marks+",'"+highest_degree_college_name+"',"+highest_degree_passout_year+""
+",'"+previous_degree_1+"',"+previous_degree_1_marks+",'"+previous_degree_1_college_name+"',"+previous_degree_1_passout_year+","
+"'"+previous_degree_2+"',"+previous_degree_2_marks+",'"+previous_degree_2_college_name+"',"+previous_degree_2_passout_year+","
+""+years_of_experience+",'"+gender+"','"+father_name+"','"+pan_card_number+"','"+passport_number+"','"+passport_expiry_date+"','Active')";

System.out.println(query);
Connect c= new Connect();
try {
c.dml(query);
c.logger(type, "Insert");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
